﻿@model WarOfDev.Web.ViewModels.UserViewModel
@{
    ViewBag.Title = "Create";
}
<h2>
    Create</h2>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>User</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Password)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.IsLocked)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsLocked)
            @Html.ValidationMessageFor(model => model.IsLocked)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.GroupId)
        </div>
        <div class="editor-field">
            @Html.DropDownList("GroupId", "Select Department")
            @Html.ValidationMessageFor(model => model.GroupId)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Roles)
            @Html.ValidationMessageFor(model => model.IsLocked)
        </div>
        <div class="editor-field">
            <div id="roleList">
                @Html.Action("GetAllRoles", new { roles = Model == null ? string.Empty : Model.Roles, groupId = Model == null ? string.Empty : Model.GroupId })
            </div>
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")   
</div>
<script type="text/javascript">

    $("#GroupId").change(function () {
        var groupId = $(this).val();

        $.ajax({
            url: 'User/GetAllRoles/roles=@(Model==null? string.Empty : Model.Roles)&groupId=@( Model == null ? string.Empty : Model.GroupId)'
        });
    });
</script>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
